﻿define([
    'Xjs/core/util',
    'Xjs/ui/Container',
// Include the modules that register the types of the components of the table row
    'Xjs/ui/table/TableBodyRow'
],
function (util, Container) {
    'use strict';

    var type = 'tableBody',
    TableBody = Xjs.getType(type);

    if (TableBody) { // It has been already loaded
        return TableBody;
    }

    TableBody = util.define({
        base: Container,
        construct: function (conf, parent) {
            TableBody.base.constructor.call(this, conf, parent); // Call the base constructor
        },
        tag: 'tbody',
        type: type,
        defaultChildType: 'tableBodyRow', // Set the default type of the child to be created
        childrenProperty: 'rows',
        getTable: function () {
            return this.parent;
        },

        createRow: function (conf) {

            var row = Xjs.create('tableBodyRow', conf, this);

            this.addChild(row);
            return row;
        },

        getRow: function (i) {
            return this.children[i];
        }
    });

    Xjs.registerType(TableBody);

    return TableBody;
});